# linux编译.o文件
# CC = cc
# ROOTPATH=../..
# INCLUDE = -I./applications -I$(ROOTPATH)/inc
# LIB=-lpthread
# OBJ += $(patsubst %.c, %.o, $(wildcard applications/*.c))
# OBJ += $(patsubst %.c, %.o, $(wildcard $(ROOTPATH)/src/*.c))
# OBJ += $(patsubst %.c, %.o, $(wildcard $(ROOTPATH)/samples/*.c))
# CFLAGS = -O0 -g3 -Wall
# target = FlashDBLinuxDemo
# all:$(OBJ)
# 	$(CC) out/*.o -o $(target) $(LIB)
# 	mv $(target) out
# %.o:%.c
# 	$(CC) $(CFLAGS) -c $< -o $@ $(INCLUDE)
# 	mv $@ out
# clean:
# 	rm -rf out/*

# linux编译.so文件
# CC = cc
# ROOTPATH = ../..
# INCLUDE = -I./applications -I$(ROOTPATH)/inc
# LIB = -lpthread
# # 使用 out 目录存放所有的对象文件
# OBJ_DIR = out
# OBJ += $(patsubst %.c, $(OBJ_DIR)/%.o, $(wildcard applications/*.c))
# OBJ += $(patsubst %.c, $(OBJ_DIR)/%.o, $(wildcard $(ROOTPATH)/src/*.c))
# OBJ += $(patsubst %.c, $(OBJ_DIR)/%.o, $(wildcard $(ROOTPATH)/samples/*.c))
# CFLAGS = -O0 -g3 -Wall -fPIC
# LDFLAGS = -shared
# target = libflashdb.so
# all: $(target)
# $(target): $(OBJ)
# 	$(CC) $(LDFLAGS) $(OBJ) -o $(target) $(LIB)
# 	mkdir -p $(OBJ_DIR)
# 	mv $(target) $(OBJ_DIR)
# $(OBJ_DIR)/%.o: %.c
# 	@mkdir -p $(dir $@)
# 	$(CC) $(CFLAGS) -c $< -o $@ $(INCLUDE)
# clean:
# 	rm -rf $(OBJ_DIR)/*

# windows编译.so文件
# CC = gcc
# CC = x86_64-w64-mingw32-gcc 32位兼容使用D:\cygwin64\bin包下另一个gcc
CC = x86_64-pc-cygwin-gcc
ROOTPATH = ../..
INCLUDE = -I./applications -I$(ROOTPATH)/inc
# Windows 上不需要 -lpthread
LIB = 
# 使用 out 目录存放所有的对象文件
OBJ_DIR = out

OBJ += $(patsubst %.c, $(OBJ_DIR)/%.o, $(wildcard drivers/*.c))
OBJ += $(patsubst %.c, $(OBJ_DIR)/%.o, $(wildcard applications/*.c))
OBJ += $(patsubst %.c, $(OBJ_DIR)/%.o, $(wildcard $(ROOTPATH)/src/*.c))
OBJ += $(patsubst %.c, $(OBJ_DIR)/%.o, $(wildcard $(ROOTPATH)/samples/*.c))

CFLAGS = -O0 -g3 -Wall -fPIC
LDFLAGS = -shared
target = libflashdb.dll
all: $(target)

$(target): $(OBJ)
	$(CC) $(LDFLAGS) $(OBJ) -o $(target) $(LIB)
	mkdir -p $(OBJ_DIR)
	mv $(target) $(OBJ_DIR)

$(OBJ_DIR)/%.o: %.c
	@mkdir -p $(dir $@)
	$(CC) $(CFLAGS) -c $< -o $@ $(INCLUDE)

clean:
	rm -rf $(OBJ_DIR)/*



